Hurdle 1: What will the output of the following program.
In [1]:
class A:
def f(self):
return self.g()
def g(self):
return 'A'
class B(A):
def g(self):
return 'B'
a = A()
b = B()
print (a.f(), b.f())
print (a.g(), b.g())
In [2]:
class Circle(object):
color = "red"
class NewCircle(Circle):
color = "blue"
nc = NewCircle
print(nc)
In [3]:
print(nc.color)
In [4]:
class Person:
def __init__(self, id):
self.id = id
sam = Person(100)
sam.__dict__['age'] = 49
print (sam.age + len(sam.__dict__))
In [5]:
class A:
def __init__(self):
self.calcI(30)
print("i from A is", self.i)
def calcI(self, i):
self.i = 2 * i;
class B(A):
def __init__(self):
super().__init__()
def calcI(self, i):
self.i = 3 * i;
b = B()
In [ ]:
In [ ]: